<html>
<head>
	
	<style type="text/css">

	a {
		text-decoration:none;
	}
	</style>
	</head>
<?php

include('functions.php');

dbConnect();

if(isLi()){

$liUser = liUser();

$liDomain = liDomain();

$userPosts = mysql_query("SELECT * FROM posts WHERE username = '$liUser' AND domain = '$liDomain'");

echo '<table border="0" cellspacing="0" cellpadding="0" style="color:white;font-size:1em;">';

$rowDescription = null;

echo '<div style="color:white;padding-left:2px;border-bottom:1px white solid"><b>' . liUser() . '@' . liDomain() . ' posts</b>';

echo ' - <a href="' . getUrl() . 'contact.php?contact=bug" target="_top">Report a bug</a>';

echo ' - <a href="' . getUrl() . 'disclaimer.php" target="_top">Disclaimer</a>';

echo ' - <a href="' . getUrl() . 'contact.php" target="_top">Contact</a>';

echo ' - <a href="' . getUrl() . 'deleteAccount.php" target="_top">Delete Account</a>';

echo '</div>';

while($row = mysql_fetch_array($userPosts)){
	

	$rowDescription = substr($row['description'], 0, 180) . "...";
	
	$rowItem = substr($row['item'], 0, 20);
	
	date_default_timezone_set('America/Denver');
	$deleted = new DateTime($row['created']);
	$todaysDate = date('d.m.y');
	$today = new dateTime($todaysDate);
	$deleted->modify("+60 day");

	$interval = $today->diff($deleted);
	
	
	echo '<tr>';
		echo '<td style="padding-right:10px;padding-left:10px"><b>' . $rowItem . '</b></td><td style="padding-right:10px"><b>(' . $interval->format('%R%a') . ' days left)</b></td><td>' . $rowDescription . '  </td>';
		echo '<td> <form target="_top" style="margin:0px; padding:0px;" name="editItem" action="modifyItem.php" method="post">';
		echo '<input type="hidden" value="' . $row['id'] . '" name="id">';
		echo '<input type="hidden" name="edit" value="true">';
		echo '<input type="submit" value="Edit" />';
		echo '</form></td>';
		echo '<td> <form target="_top" style="margin:0px; padding:0px; name="deleteItem" action="modifyItem.php" method="post">';
		echo '<input type="hidden" value="' . $row['id'] . '" name="id">';
		echo '<input type="hidden" name="delete" value="true">';
		echo '<input target="_top" type="submit" value="Delete" />';
		echo '</form></td>';
	echo '</tr>';
}

echo '</table>';
} else { ?>


	<?php /*<div id="login_link" style="background:#6d8ca0;<?= $display ?>height:100px;clear:both;padding-right:10px;padding-bottom:10px; margin-bottom:20px;border-bottom:1px solid white;">*/ ?>

	<table>
	<tr>
		<td>			
			<div style="padding-right:15px; padding-bottom:25px; padding-top:25px;border-right:1px solid white;margin-left:10px">
				<h1>Welcome!</h1>
			</div>
		</td>

		<td>
	<div style="color:white;margin-top:0px;padding-left:0px;margin-left:0px">
	<ul>
		<li style="padding-bottom:4px;">To sign up for CollegeHustler you must have a valid university email address</li>
		<li style="padding-bottom:4px;">To contact sellers you must have a valid CollegeHuster account</li>
		<li style="padding-bottom:4px;">Your email address will never be revealed to anyone</li>
		<li style="padding-bottom:4px;">Read the rules for CollegeHustler, <a href="<?= getUrl() ?>disclaimer.php"><b>disclaimer!</b></a></li>
	</ul>
	</div>
	</td>
	<td>,
	<div style="color:white;padding-left:15px; border-left:1px solid white;padding-right:50px;margin-left:15px; border-right:1px solid white;">
		<b>One Click Sign Up!!</b>
		<form action="signup.php?signup" method="post">
		<input type="text" size="11" name="username" "/>
		<select name="domain">
			<?php
			$domain_result = mysql_query("SELECT domain, name FROM domains");

			while($row = mysql_fetch_assoc($domain_result)){
				echo '<option value = "' . $row['domain'] . '">@' . $row['domain'] . '</option>';
			}

			?>
		</select>
		<input type="submit" value="Start hustling" />
		</form><br />
		<i>Is your university not listed? <a href="contact.php">Contact Us<a/></i><br />
	</div>
	</td>
	<td>
	<div style="padding-left:10px; padding-top:10px">

		<form name="input" action="login.php" method="post">
			<input type="text" size="10" value="username" name="username" />
			<select name="domain">
				<?php
				$domain_result = mysql_query("SELECT domain, name FROM domains");

				while($row = mysql_fetch_assoc($domain_result)){
					echo '<option value = "' . $row['domain'] . '">@' . $row['domain'] . '</option>';
				}

				?>
			</select><br />
			<input type="password" size="25" name="password" value="password" /><br />
			<input type="hidden" name="loginSubmitted" value="TRUE">
			<input type="submit" value="Login" />
			<a href="<?= getUrl(); ?>recoverPassword.php">Recover Password</a>
		</form>
	</div>
	</td>
	</tr>
	</table>

<?php	
} 

?>